package service.calculator.bonchon.paseo;

import java.math.BigDecimal;

import models.Payment;
import models.Rate;
import service.BillingCalculator;
import service.calculator.bonchon.BonchonBillingCalculatorImpl;
import service.calculator.bonchon.BonchonPaymentType;
import util.Rounder;

public class BonchonPaseoBillingCalculatorImpl extends
		BonchonBillingCalculatorImpl implements BillingCalculator {

	@Override
	public BigDecimal calculatePayment(Rate rate, Payment payment) {
        BigDecimal paymentCalculation = null;
        BonchonPaymentType paymentType = BonchonPaymentType
                .valueOf(payment.paymentType);
        BigDecimal paymentHrs = BigDecimal.valueOf(payment.hours);

        switch (paymentType) {
        case ECOLA:
        case CTPA:
            paymentCalculation = BigDecimal.valueOf(1.5625).multiply(paymentHrs);
            paymentCalculation = Rounder.roundup(paymentCalculation);
            break;
        default:
            paymentCalculation = super.calculatePayment(rate, payment);
        }

        return paymentCalculation;
    }

	@Override
	protected BigDecimal computeGovernmentBenefitsPerHour() {
		// Per day is computed by monthly/26 days.
		BigDecimal thirteenthMonthPayPerDay = BigDecimal.valueOf(26.25);
		BigDecimal sssPerDay = BigDecimal.valueOf(24.08);
		BigDecimal philhealthPerDay = BigDecimal.valueOf(0.48);
		BigDecimal pagIbigPerDay = BigDecimal.valueOf(3.85);
		BigDecimal ecMcPerDay = BigDecimal.valueOf(0.38);

		BigDecimal governmentBenefits = BigDecimal.valueOf(0.00);
		governmentBenefits = governmentBenefits.add(thirteenthMonthPayPerDay);
		governmentBenefits = governmentBenefits.add(sssPerDay);
		governmentBenefits = governmentBenefits.add(philhealthPerDay);
		governmentBenefits = governmentBenefits.add(pagIbigPerDay);
		governmentBenefits = governmentBenefits.add(ecMcPerDay);

		// Compute per hour
		governmentBenefits = governmentBenefits.divide(BigDecimal.valueOf(8));

		return governmentBenefits;
	}

}
